package com.qz.recursion;

/**
 * @Description
 * @Author Flag
 * @Date: 2021/7/25 19:46
 * @Version: 1.0
 **/
public class RecursionTest {
    public static void main(String[] args) {
//        test(4);

        System.out.println(factorial(3));
    }


    /**
     * 打印问题
     * @param n
     */
    public static void test(int n){
        if(n>2){
            test(n-1);
        }
        System.out.println("n="+n);
    }

    //阶乘
    public static int factorial(int n) {
        if (n == 1) {
            return 1;
        } else {
            return factorial(n - 1) * n;
        }
    }

}
